package zmee.pur.src.common;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.scm.src.common.calc.SrcCalcContext;
import kd.scm.src.common.calc.SrcCalcHelper;
import kd.scm.src.common.calc.rank.ISrcRankCoreCalc;
import kd.scm.src.common.calc.rank.ISrcRankResult;
import kd.scm.src.common.calc.rank.SrcRankFacade;
import kd.scm.src.common.calc.rank.SrcRankResultVerify;

import java.util.Iterator;

/**
 * @Author: xw
 * @Date: 2023/01/05/14:37
 * @Description:
 */
public class SrcRankCalcScoreAndRankExt implements ISrcRankResult {
    private static final long serialVersionUID = 1L;

    public SrcRankCalcScoreAndRankExt() {
    }

    @Override
    public void process(SrcCalcContext context) {
        if (context.getRankGKeySet() != null) {
            long billId = context.getBillId();
            QFilter filter = new QFilter("parentid", "=", billId);
            DynamicObject compareConfig = BusinessDataServiceHelper.loadSingle("src_compare_config", "extfilter", filter.toArray());
            DynamicObject extfilter = compareConfig.getDynamicObject("extfilter");
            if (extfilter != null) {
                String number = extfilter.getString("number");
                if ("negotiate004".equals(number)) {
                    return;
                }
            }
            Iterator var2 = context.getRankGKeySet().iterator();

            while (var2.hasNext()) {
                String currGKey = (String) var2.next();
                context.setCurrGKey(currGKey);
                SrcRankFacade.rankCoreCalc(context, ISrcRankCoreCalc.class.getSimpleName());
            }

            SrcCalcHelper.executeCalcPlugin(SrcRankResultVerify.class.getSimpleName(), context, true);
        }
    }
}